(1) Field of the Invention
This invention relates to a database reorganization program and method and, more particularly, to a database reorganization program and method for reorganizing a database with minimizing memory consumption.
(2) Description of the Related Art
In many database systems, databases may be reorganized so as to keep efficient data input/output operation. For example, there are following reasons:
1. Combination of free spaces between records in a page (fragmentation reduction)
2. Improvement of access performance by storing records of overflow pages into prime pages
3. Area expansion before a database becomes full of records.
In general reorganization methods, a new database with a larger capacity than an original database is first prepared. Then the records of the original database are all copied in the new database (for example, refer to Japanese Unexamined Patent Publication No. 2000-339210). This technique will be now described.
FIG. 14 shows a general method of reorganizing a database 941 into a database 951.
In this method, the database 951 (copy destination) with a larger capacity than the database 941 is newly prepared differently from the database 941 (copy source) that is used by processing functions. The databases 941 and 951 have corresponding indexes 942 and 952. In addition, each of the databases 941 and 951 has a prime page area 941a, 951a for storing plural prime pages and an overflow page area 941b, 951b for storing plural overflow pages.
Then, the database reorganization is performed by copying the records of the database 941 in the database 951 in order from the first page (step S111). During this process, a transaction 961 requesting for updating records in the database 941 is acceptable. This transaction 961, for example, changes a record (record number R1) of the prime page and adds a record (record number R33) to the overflow page (step S112) in the database 941. During the reorganization, the contents of such update operation are recorded in an update log 943 (step S113).
When an application program requests for updating records of the database 951 thereafter, the update log 943 regarding the records is reflected on the database 951 (step S114). In other words, the records to be updated in the database 951 are overwritten based on the update log 943, so as to maintain consistency. This database reorganization method is referred to as DBsnapper.
According to this method shown in FIG. 14, the copy destination database is newly prepared. Therefore, even little capacity expansion creates a new copy destination database with a larger capacity than a copy source database. That is, memory space larger than twice the amount of data to be copied is required, and the copy source database becomes useless after copy. In short, a space problem for databases and a maintenance cost problem arise.